<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <script>
    let arr=[12,5,88,37,21,91,17,24];

    let ave=arr.reduce((tmp,item,index)=>{
      if(index<arr.length-1){
        return tmp+item;
      }else{    //最后一次迭代
        return (tmp+item)/arr.length;
      }
    });

    console.log(ave);
    </script>
  </head>
  <body>

  </body>
</html>
